<template>
  <h2>用户注册</h2>
  <el-form ref="formRef" :model="form" label-width="80px">
    <el-form-item label="手机号">
      <el-input v-model="form.phone" type="text"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="form.password" type="password"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">保存</el-button>
      <el-button @click="onCancel">取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import {reactive} from 'vue';
import axios from "axios";
import router from "../router";


const form = reactive({
  phone: '',
  password: ''
})

const onSubmit = () => {
  axios.post('/api/mall-consumer/consumer/register', form)
      .then(res => {
        alert(res.data.message)
        router.push('/login')
      })
}


const onCancel = () => {
  router.push('/login')
}
</script>

<style scoped>

</style>